package com.bdqn.zhao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.zhao.pojo.IpPark;
import com.bdqn.zhao.pojo.SysDept;
import com.bdqn.zhao.dao.SysDeptMapper;
import com.bdqn.zhao.pojo.SysRole;
import com.bdqn.zhao.pojo.SysUser;
import com.bdqn.zhao.service.SysDeptService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 部门表 服务实现类
 * </p>
 *
 * @author zhangsan
 * @since 2023-04-24
 */
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
    @Autowired
    private SysDeptMapper sysDeptMapper;
    @Override
    public List<SysDept> selectAll() {
        QueryWrapper<SysDept> queryWrapper = new QueryWrapper<>();
        IPage<SysDept> sysUserIPage=new Page<>(0,10);
        IPage<SysDept> sysUserIPage1 = sysDeptMapper.selectPage(sysUserIPage, queryWrapper);
        List<SysDept> records = sysUserIPage1.getRecords();
        return records;
    }

    @Override
    public SysDept selectbyid(int id) {
        return sysDeptMapper.selectById(id);
    }

    @Override
    public int delectSysuer(int id) {
        return sysDeptMapper.deleteById(id);
    }

    @Override
    public int updatePwd(SysDept sysDept) {
        return 0;
    }

    @Override
    public int sysDeptrAdd(SysDept sysDept) {
        return sysDeptMapper.insert(sysDept);
    }

    @Override
    public List<SysDept> fuzzy(Integer pageNum, Integer pageSize, String status, String deptName) {
        QueryWrapper<SysDept> queryWrapper=new QueryWrapper<>();
        if (pageNum <= 0) {
            pageNum = 1;
        }
        Page<SysDept> page = new Page<>(pageNum, pageSize);//设置分页参数
        if (status!=null){
            queryWrapper.eq("status",status);
        } else if (status!=null&&deptName!=null) {
            queryWrapper.eq("status",status).eq("deptName",deptName);
        }
        IPage<SysDept> sysDeptIPage = sysDeptMapper.selectPage(page, queryWrapper);
        List<SysDept> sysDepts;
        sysDepts=sysDeptIPage.getRecords();
        return sysDepts;
    }

    @Override
    public List<SysDept> department() {
        return null;
    }

    @Override
    public List<IpPark> departmentyq() {
        return null;
    }

    @Override
    public List<SysRole> departmentjs() {
        return null;
    }

    @Override
    public int updatestaus(String loginName, String status) {
        return 0;
    }
}
